/*
 * File Name：NumericWheelAdapter.java
 * Copyright：Copyright 2008-2012 CiWong.Inc. All Rights Reserved.
 * Description： NumericWheelAdapter.java
 * Modify By：PLA-BBTAN
 * Modify Date：2012-11-17
 * Modify Type：Add
 */
package com.ciwong.epaper.widget.wheel.adapter;

import com.ciwong.epaper.bean.City;
import com.ciwong.epaper.widget.wheel.i.WheelAdapter;

import java.util.List;

/**
 * 地区选择适配器
 */
public class CityChooseAdapter implements WheelAdapter
{
    private List<City> mCityList;

    private int mMaxLength;

    private boolean isPad = false;

    /**
     * 
     * 默认的构造函数
     * 
     * @param list
     *            城市列表数据
     * @param maxLength
     *            最大的长度
     */
    public CityChooseAdapter(List<City> list, int maxLength, boolean isPad)
    {
        this.mCityList = list;
        this.mMaxLength = maxLength;
        this.isPad = isPad;
    }

    @Override
    public int getItemsCount()
    {
        return mCityList.size();
    }

    @Override
    public String getItem(int index)
    {
        String zoneStr = "";
        if (index >= 0 && index < getItemsCount())
        {
            zoneStr = mCityList.get(index).getZoneStr();
            if (zoneStr.length() > 6 && !isPad)
            {
                zoneStr = zoneStr.subSequence(0, 6) + "...";
            }
        }
        return zoneStr;
    }

    public void setMaxinumLength(int length)
    {
        mMaxLength = length;
    }

    @Override
    public int getMaximumLength()
    {
        return mMaxLength;
    }

}
